export const ARTICLE_INCREMENT = 'ARTICLE_INCREMENT'
export const ARTICLE_DECREMENT = 'ARTICLE_DECREMENT'

export function increment(){
    return {
        type: ARTICLE_INCREMENT
    }
}

export function decrement(){
    return {
        type: ARTICLE_DECREMENT
    }
}

export function incrementAsync(delay = 1000) {
    return (dispatch, getState) => {
        console.log(getState())
        setTimeout(() => {
            return dispatch({
                type:ARTICLE_INCREMENT
            })
        }, delay)
    }
}

export default function listReducer(state = 0, action) {
    switch (action.type){
        case ARTICLE_INCREMENT:
            return state + 1
        case ARTICLE_DECREMENT:
            return state - 1
        default:
            return state
    }
}
